import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { JqtCpHtOrderVO, JqtCpHtOrderForm, JqtCpHtOrderQuery, JqtCpHtBuyMonthsVo } from '@/api/bus/jqtCpHtOrder/types';
import { JqtCpHtUserBuyForm } from '@/views/bus/jqtCpHtUserBuy/index.vue';

/**
 * 查询企业互通订单列表
 * @param query
 * @returns {*}
 */

export const listJqtCpHtOrder = (query?: JqtCpHtOrderQuery): AxiosPromise<JqtCpHtOrderVO[]> => {
  return request({
    url: '/bus/jqtCpHtOrder/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询企业互通订单详细
 * @param id
 */
export const getJqtCpHtOrder = (id: string | number): AxiosPromise<JqtCpHtOrderVO> => {
  return request({
    url: '/bus/jqtCpHtOrder/' + id,
    method: 'get'
  });
};

/**
 * 新增企业互通订单
 * @param data
 */
export const addJqtCpHtOrder = (data: JqtCpHtOrderForm) => {
  return request({
    url: '/bus/jqtCpHtOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改企业互通订单
 * @param data
 */
export const updateJqtCpHtOrder = (data: JqtCpHtOrderForm) => {
  return request({
    url: '/bus/jqtCpHtOrder',
    method: 'put',
    data: data
  });
};

/**
 * 删除企业互通订单
 * @param id
 */
export const delJqtCpHtOrder = (id: string | number | Array<string | number>) => {
  return request({
    url: '/bus/jqtCpHtOrder/' + id,
    method: 'delete'
  });
};

/**
 * 获取购买互通账号时长和价格
 * @param id
 */
export const getBuyMonths = (): AxiosPromise<JqtCpHtBuyMonthsVo[]> => {
  return request({
    url: '/bus/jqtCpHtOrder/getBuyMonths',
    method: 'get'
  });
};
/**
 * 购买互通账号
 * @param data
 */
export const payHtAccount = (data: JqtCpHtUserBuyForm) => {
  return request({
    url: '/bus/jqtCpHtOrder/payHtAccount',
    method: 'post',
    data: data
  });
};

/**
 * 查询订单支付状态
 * @param data
 */
export const getOrderPayStatus = (serialNumber:string) => {
  return request({
    url: '/bus/jqtCpHtOrder/getOrderPayStatus',
    method: 'post',
    data: {
      serialNumber
    }
  });
};
